package com.cc.controller;

import com.cc.entity.ProductTypes;
import com.cc.service.ProductService;
import com.cc.service.ProductTypesService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 33314
 * @version 1.0
 * @description: TODO
 * @date 2025/6/24 18:53
 */
@RestController
@RequestMapping("/pro")
public class ProductTypesController {
    @Autowired
    private ProductTypesService productTypeService;

    @RequestMapping("/getProductTypes")
    public List<Map<String, Object>> getProductTypes() {
        List<ProductTypes> productTypes = productTypeService.getAllProductTypes();
        List<Map<String, Object>> result = new ArrayList<>();
        for (ProductTypes type : productTypes) {
            Map<String, Object> map = new HashMap<>();
            map.put("typeId", type.getTypeId());
            map.put("typeName", type.getTypeName());
            result.add(map);
        }
        return result;
    }
}
